package com.wh1200.mybatis.xmlless.resolver

import com.wh1200.mybatis.xmlless.config.BaseResolverTest
import com.wh1200.xmlless.test.dao.MenuDAO
import org.junit.jupiter.api.DisplayName
import org.junit.jupiter.api.Test
import kotlin.reflect.jvm.javaMethod
import kotlin.test.assertContains
import kotlin.test.assertEquals
import kotlin.test.assertNotNull

/**
 *
 * @author wuhao
 * @date 2024/1/27 23:44
 * @since v0.0.0
 * @version 1.0
 */

class MenuDAOResolver: BaseResolverTest(
    MenuDAO::class.java
) {

  @Test
  fun testFindByUserId() {
    val method = MenuDAO::findByUserId.javaMethod!!
    val query = createQueryForMethod(method)
    val sql = query.sql
    assertNotNull(sql)
  }

  @Test
  @DisplayName("清空所有记录")
  fun clean() {
    val method = MenuDAO::clean.javaMethod!!
    val query = createQueryForMethod(method)
    query.exception?.printStackTrace()
    val sql = query.sql
    assertNotNull(sql)
    assertContains(sql, "TRUNCATE TABLE menu")
  }

}
